<template>
  <view>
		<h3 style="background-color: #ffffff; border-radius: 10px 10px 0 0; box-shadow: 0 8px 50px #9d9d9d33; height: 80rpx; width: 750rpx; line-height: 80rpx; text-align: center;">联系人信息</h3>
		<view style="max-height: 80vh; padding: 20rpx 30rpx; overflow-y: auto;">
			<u-form
				:model="basicForm"
				:rules="rules"
				labelPosition="top"
				ref="form"
				labelWidth="auto"
				:labelStyle="{
					fontSize: '14px',
					color: '#B2B2B2',
					lineHight: '20px'
				}"
			>
				<u-form-item label="联系人" prop="lxr" required>
					<u--input placeholder="请输入联系人" v-model="basicForm.lxr"></u--input>
				</u-form-item>
				
				<u-form-item label="联系电话" prop="lxfs" required>
					<u--input placeholder="请输入联系电话" v-model="basicForm.lxfs"></u--input>
				</u-form-item>
			</u-form>
		</view>
		<view class="space-x-1 mt-1" style="display: flex; padding: 10rpx 30rpx; box-shadow: 50px 50px 8px 50px #23232333;">
			<u-button type="primary" text="关闭" :plain="true" :loading="loading" @click="onClose"></u-button>
		  <u-button type="primary" text="保存" :loading="loading" @click="onSubmit" :throttleTime="500"></u-button>
		  
		</view>
  </view>
</template>

<script>
import { queryProvisionBroadList, queryProvisionSmallList } from '@/api/purchase/ErpPurchaseCannibalizeForm'
import { erpPurchaseCannibalizeCheckStock } from '@/api/index'

export default {
  name: 'ContactForm',
  props: {
    teamId: '',
    companyId: '',
    // 表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false,
    },
		exportWarehouse: {
			type: String,
			default: '',
			required: false
		},
		storehouseName:{
			type: String,
			default: '',
			required: false
		},
    datailDisabled: {
      type: Boolean,
      default: false,
    },
    index: {
      type: Number,
      default: null,
    },
  },
  data() {
    return {
      smallList: [],
      loading: false,
      basicForm: {
        lxr: '',
				lxfs: ''
      },
      rules: {
				lxfs: [
					{ required: true, message: '请输入联系电话!', trigger: ['change', 'blur'] },
					{ required: true, pattern: /(^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$)|(^\/$)/, message: '请输入正确的联系电话!', trigger: ['change', 'blur'] }
				],
        lxr: [{ required: true, message: '请输入联系人!', trigger: ['change', 'blur'] }]
      },
    }
  },
  created() {},
  methods: {
    reset() {
      this.$refs.form.resetFields()
    },
    async onSubmit() {
      await this.$refs.form.validate()
      if (!this.index) {
        this.$emit('submit', [
          {
            ...this.basicForm,
          },
          this.index,
        ])
      } else {
        this.$emit('submit', [this.basicForm, this.index])
      }
			
			this.$refs.form.resetFields()
    },
    onClose() {
      this.$emit('close')
			this.$refs.form.resetFields()
    },
  },
}
</script>

<style lang="scss" scoped>
	/deep/ .u-form-item__body__left__content__required {
		left: 0px !important;
	}
	/deep/ .u-form-item__body__left__content__label{
		padding-left: 20rpx !important;
	}
</style>
